<?php
include "../../fun.php";
isLogin();
$db=conndb();
$news_name=$_POST["news_name"]; //获取索引
$sortid=$_POST["sortid"];
$content=isset($_POST["content"])?$_POST["content"]:'';
$time=strtotime($_POST["time"]);
$id=isset($_POST["id"])?$_POST["id"]:'';
if ($id) {
    $sql="update news set news_name='{$news_name}',content='{$content}',sortid='{$sortid}',time='{$time}' where id='{$id}'";
} else {
    $sql="insert into news (news_name,content,sortid,time) values ('{$news_name}','{$content}','{$sortid}','{$time}')";
}
$db->exec($sql);
$data=["code"=>0,"msg"=>"操作成功"];
echo json_encode($data, JSON_UNESCAPED_UNICODE);
